package com.gitee.srurl.snow.backwards;

import com.gitee.srurl.snow.gen.AbstractSnowflake;
import com.gitee.srurl.snow.gen.BorrowFutureTimeSnowflake;
import com.gitee.srurl.snow.domain.SnowflakeData;

/**
 * 如果发生时钟回拨 借用以后的时间
 *
 * @author zxw
 * @date 2023/4/22 10:41
 */
public class BorrowFutureTime extends AbstractBackwards {

    private final AbstractSnowflake abstractSnowflake;

    public BorrowFutureTime(long lastTimestamp, SnowflakeData snowflakeData) {
        super(lastTimestamp, snowflakeData);
        abstractSnowflake = new BorrowFutureTimeSnowflake(lastTimestamp, snowflakeData);
    }

    @Override
    public long nextId() {

        return abstractSnowflake.nextId();
    }

    @Override
    public long getLastTimestamp() {

        return this.abstractSnowflake.getLastTimestamp();
    }
}
